using UnityEngine;
using System.Collections;

public class NPC : Character {
	
	//keep it from going into the high octave range
	public const int MAX_NPC_NOTE = 59;
	
	private const float MAX_JUJU_TIME = 10;
	
	//how high above the player should the heart sit?
	const float HEART_VERT_OFFSET = 150;
	
	//The character's heart
	private tk2dSprite heart;
	
	private float happyTime;
	private float sadTime;
	
	private float jujuTimeStart;
	private float currJujuTime;
	private bool happy;
	private bool sad;
	
	// Use this for initialization
	override protected void Start () {
		//Juju = .5f;//start halfway dead
		base.Start();
		heart = (tk2dSprite)Instantiate(Resources.LoadAssetAtPath("Assets/Prefabs/HeartPrefab.prefab", typeof(tk2dSprite)));// ) as GameObject;
		
	}
	
	//Updates heart's position and color, on spectrum from blue to red, based on love
	private void updateHeart() {
		xMovement = 1;
		
		heart.transform.position = new Vector3(transform.position.x, transform.position.y+HEART_VERT_OFFSET, transform.position.z);
		heart.color = new Color(love, 0, 1-love, Juju);
	}
	
	
	override protected void Update () {
		base.Update ();
		//update color based on how much I like things, based on proximity
		updateHeart();
		
		/*if(sad && love > .5f) {
			happy = true;
			sad = false;
			jujuTimeStart = Time.timeSinceLevelLoad;
			sadTime = currJujuTime;
			currJujuTime = 0;
		} else if (happy && love < .5f){
			jujuTimeStart = Time.timeSinceLevelLoad;
			happy = false;
			sad = true;
			happyTime += currJujuTime;
			currJujuTime = 0;
		}
		
		if (happy || sad) {
			currJujuTime = Time.timeSinceLevelLoad - jujuTimeStart;
		} 
		
		Juju = .5f + .5f * sadTime/MAX_JUJU_TIME + .5f * happyTime/MAX_JUJU_TIME;*/
	}
}
